import uvicorn
from fastapi import FastAPI,Query
from typing import Optional,List
from pydantic import BaseModel

app = FastAPI()


# @app.get("/items/")  #当你在使用 Query 且需要声明一个值是必需的时，可以将 ... 用作第一个参数值。
# def read(pwd: str = Query(..., min_length=6,max_length=10))
#     results = {"items": [{"oneid": "shanghai"}, {"two": "beijing"}]}
#     if pwd:
#         results.update({"paword": pwd})
#     return results


'''
  当我们传递 多个值，应该如何实现呢

'''

@app.get("/items/")
def read(paword: Optional[List[str]] = Query(None)):
    results = {"items": [{"oneid": "shanghai"}, {"two": "beijing"}]}
    if paword:
        results.update({"paword": paword})
    return results

if __name__ == '__main__':
    uvicorn.run(app="main:app", host="127.0.0.1", port=8000, reload=True, debug=True)
